const http = require("http");

console.log("=====GET=====");
http.get("http://127.0.0.1:8000/login", (res) => {
  res.on("data", (data) => {
    console.log(data.toString());
  });

  res.on("end", () => {
    console.log("获取了所有的结果");
  });
});

console.log("=====POST=====");
const req = http.request(
  {
    method: "POST",
    hostname: "localhost",
    post: 8000,
  },
  (res) => {
    res.on("data", (data) => {
      console.log(data.toString());
    });
    res.on("end", () => {
      console.log("获取了所有的结果");
    });
  }
);
req.end();
